![]() |
PATH![]() |
![]() ![]() |
To use the value of a variable in a script, include the variable in a command or expression. For example, the first statement in the following example creates a variable, called myName , whose value is the string "Steve" . The second statement uses the variable myName in place of a string as the default answer parameter of the Display Dialog scripting addition command.
set myName to "Steve"
display dialog "What is your name?" default answer myName
If you assign a new value to a variable, it replaces the old value. The following script shows what happens when you assign a new value. It uses the Display Dialog command to display the values. Try running this script:
set myName to "Steve"
display dialog ("The value of myName is now " & myName) ¬
buttons "Sure Is" default button 1
set myName to "John"
display dialog ("The value of myName is now " & myName) ¬
buttons "You Betcha" default button 1
The first Display Dialog command displays the value stored by the first assignment statement (the string "Steve" ). The next Display Dialog command displays the value after the second assignment statement (the string "John" ).